package com.taotao.portal.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.portal.pojo.ItemInfo;
import com.taotao.portal.service.ItemService;

@Controller
// @RequestMapping("/item")
public class ItemController {
	@Autowired
	private ItemService itemService;

	@RequestMapping("/item/{itemId}")
	public String getItemById(@PathVariable("itemId") Long id, Model model) {
		ItemInfo itemInfo = itemService.getItemById(id);
		model.addAttribute("item", itemInfo);
		return "item";
	}

	@RequestMapping(value = "/item/desc/{itemId}", produces = MediaType.TEXT_HTML_VALUE + ";charset=utf-8")
	public @ResponseBody String getItemDescById(@PathVariable("itemId") Long id) {
		String desc = itemService.getItemDescById(id);
		return desc;
	}

	@RequestMapping(value = "/item/param/{itemId}", produces = MediaType.TEXT_HTML_VALUE + ";charset=utf-8")
	public @ResponseBody String getItemParamById(@PathVariable("itemId") Long itemId) {
		String result = itemService.getItemParamByItemId(itemId);
		return result;
	}
}
